<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="../common.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>监控项报警数据列表</title>
<script>

// 加载列表
function loadList(columns, dataList){
	// 初始化列表
	$('#list').datagrid({
		height: size.height-120,
		idField: 'id',
		nowrap: false, //内容换行
		striped: true, //条纹
        fit: true,
		singleSelect: true, //是否单选
        frozenColumns: [[
        	{field:'ck',checkbox:true}
        ]],
		columns: columns,
		rownumbers : true, //记录号
		pagination : false,
	}); 
	
	// 加载数据
	$("#list").datagrid("loadData", dataList);  //动态取数据		
}


$(function() { 
	var itemId = $("#itemId").val();
	// 获取数据
	$.ajax({
		url: '${ctx}/monitorItem/monitorItemAlarmList?itemId='+itemId,
		type: "POST",
		dataType:'json',
		success: function(opt){
			var fieldList = opt.fieldList;
			// 初始化列表列
			var columns = "[[";  
			for(var i=0; i<fieldList.length; i++){
				columns += '{"field":"'+fieldList[i]+'","title":"'+fieldList[i]+'","align":"center","width":"100"},';
			}
			if(columns.length>0){
				columns = columns.substring(0,columns.length-1);
			}
			columns += "]]";
			loadList(JSON.parse(columns), opt.dataList);	
		}
	});

});
</script>
</head>
<body class="easyui-layout">
<input type="hidden" id="itemId" name="itemId" value="${itemId}" />
<!-- 列表 -->
<div data-options="region:'center'" style="overflow: hidden;">
    <table id="list"></table>
</div> 
</body>
</html>